import { Viewer } from 'cesium';

export const createViewer = (container: Element | string, options: Viewer.ConstructorOptions = {}) => {
  const viewer = new Viewer(container, {
    geocoder: false,
    homeButton: false,
    sceneModePicker: false,
    navigationHelpButton: false,
    baseLayerPicker: false,
    infoBox: false,
    animation: false,
    fullscreenButton: false,
    timeline: false,
    ...options,
  });

  if (import.meta.env.VITE_CESIUM_HIDE_CREDIT === 'true') {
    // @ts-expect-error 隐藏水印：内部属性。
    viewer._cesiumWidget._creditContainer.style.display = 'none';
  }

  return viewer;
};
